//
//  LesInforViewController.m
//  fp
//
//  Created by xingshuai on 2020/11/13.
//

#import "LesInforViewController.h"

#import "LessInforTop.h"
#import "RoomCollectionViewCell.h"

static NSString *identifier = @"XAJiaKeInforCollectionCellID";

@interface LesInforViewController () <UICollectionViewDelegate, UICollectionViewDataSource>
// 头部视图（学校信息）
@property (nonatomic, strong) LessInforTop *inforTopView;
// 数据展示
@property (nonatomic, strong) UICollectionView *collection;

@end

@implementation LesInforViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.currentnavType = XSCurrentNavViewTypeUser;
    self.navColor = [UIColor clearColor];
    self.navString = @"校师佳课";
    self.navTitleColor = [UIColor colorWithHexString:@"#4E75FF"];
    self.userBackImg = @"home_back";
    self.viewBackImg.hidden = NO;    // 页面背景图片 schoolInfoTop
    self.lineView.hidden = YES;
    
    [self creatViewUI];
    
}
// 初始化UI
-(void)creatViewUI {
    [self.view addSubview:self.inforTopView];
    [self.inforTopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(self.navView.mas_bottom).offset(10);
        make.height.mas_offset((ScreenWidth-30)/4.5+15);
    }];
    
    [self.view addSubview:self.collection];
    [self.collection mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(15);
        make.top.equalTo(self.inforTopView.mas_bottom);
        make.right.equalTo(self.view.mas_right).offset(-15);
        make.bottom.equalTo(self.view).offset(-5);
    }];
}

-(LessInforTop *)inforTopView {
    if (!_inforTopView) {
        _inforTopView = [[LessInforTop alloc]init];
    }
    return _inforTopView;
}

// 初始化collection
- (UICollectionView *)collection {
    if (!_collection) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.minimumLineSpacing = 20;
        flowLayout.minimumInteritemSpacing = 10;
        flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        
        _collection = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
        [_collection registerClass:[RoomCollectionViewCell class] forCellWithReuseIdentifier:identifier];
        _collection.showsHorizontalScrollIndicator = NO;
        _collection.dataSource = self;
        _collection.delegate = self;
        _collection.backgroundColor = [UIColor clearColor];
        _collection.showsVerticalScrollIndicator = NO;
        _collection.contentInset = UIEdgeInsetsMake(20, 0, 0, 0);
    }
    return _collection;
}

#pragma mark - UICollectionViewDelegateFlowLayout
// 返回cell的尺寸大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake((self.collection.frame.size.width-30)/4, (self.collection.frame.size.width-30)/4);
}

#pragma mark - deleDate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 24;
}

// cell内容
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

    RoomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
